package spring.mybatis.factoryBean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import spring.mybatis.mapper.UserMapper;
import spring.mybatis.service.UserServiceImpl;

/**
 * mybatis-spring 通过 MapperFactoryBean 单独配置 Mapper接口
 *
 * @author ME
 * @date 2021/5/20
 */
public class TestMybatisMapper {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring/mybatis/factoryBean/spring-mapper.xml");

        UserServiceImpl service = context.getBean(UserServiceImpl.class);
        System.out.println("UserService: " + service.getUser(4));
        System.out.println();

        UserMapper mapper = context.getBean(UserMapper.class);
        System.out.println("UserMapper: " + mapper.getUser(3));
    }

}
